// collection.js
import api from "../../../utils/api"
import util from "../../../utils/util"
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    current:0,
    sweiperHeight:1000,
    redMothorList: [],
    courseList:[],
    caseList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // util.isLogin();
    console.log("----------------->");
    console.log(app.globalData);
    util.isLogin();
    //收藏红娘
    this.getColletcionRm();
    //收藏课程
    this.getCollectionCourse();
    //收藏案例
    this.getCollectionCase();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  /**
   * 切换tab页
   */
  swiperChange:function(e){
    this.setData({
      current:e.detail.current
    });
  },
  changeTab:function(e){
    this.setData({
      current:e.target.dataset.index
    });
    if(e.target.dataset.index==0){

    }
  },
  /**
   * 获取收藏红娘
   */
  getColletcionRm:function(){
    // debugger;
    var that = this;
    wx.request({
      url: api.saveRedmothorList,
      data:{
        id:app.globalData.openid,
      },
      type:"POST",
      header: {
        "content-type": "application/x-www-form-urlencoded"
      },
      success:function(response){
        // getColletcionRm();
        console.log("收藏红娘列表");
        console.log(response.data.data);
        that.setData({
          redMothorList:response.data.data
        });
      }
    })
  },
  /**
   * 获取收藏课程
   */
  getCollectionCourse:function(){
    var that = this;
    // debugger;
    wx.request({
      url: api.qcoursetrovey,
      data: {
        id: app.globalData.openid,
      },
      type: "POST",
      header: {
        "content-type": "application/x-www-form-urlencoded"
      },
      success: function (response) {
        // getColletcionRm();
        console.log("收藏课程列表");
        console.log(response.data.data);
        that.setData({
          courseList: response.data.data
        });
      }
    })
  },
  /**
   * 获取收藏案例
   */
  getCollectionCase:function(){
    var that = this;
    // debugger;
    wx.request({
      url: api.qcasustrovey,
      data: {
        id: app.globalData.openid,
      },
      type: "POST",
      header: {
        "content-type": "application/x-www-form-urlencoded"
      },
      success: function (response) {
        // getColletcionRm();
        console.log("收藏案例列表");
        console.log(response.data.data);
        that.setData({
          caseList: response.data.data
        });
      }
    })
  }
})